//
// Created by Zhao Ziqiu on 2021/8/22.
//

#ifndef NODE_MUSIC_PLAYER_PREPAREWORKER_H
#define NODE_MUSIC_PLAYER_PREPAREWORKER_H

#include <napi.h>
#include <string>
#include "player-impl.h"
using namespace std;
using namespace Napi;

class PrepareWorker : public AsyncWorker {
public:
    PrepareWorker(Napi::Env env, PlayerImpl* playerImpl, const string& url)
    :AsyncWorker(env),
    mPlayerImpl(playerImpl),
    mDeferred(Promise::Deferred::New(env)) {
        mUrl = url;
    }
    ~PrepareWorker() override;
    void Execute() override;
    void OnOK() override;
    PlayerImpl* mPlayerImpl;
    Promise::Deferred mDeferred;
    string mUrl;
};


#endif //NODE_MUSIC_PLAYER_PREPAREWORKER_H
